# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
#
# Examples:
#   
#   cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
#   Major.create(:name => 'Daley', :city => cities.first)
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Base.colorize_logging = false

organizations = ['ACOX', 'CSE', 'ACOT', 'ACOI']
employments = ['Active Duty', 'Civilian', 'Contractor', 'Guard/Reserve']
statuses = ['Duty', 'Leave', 'TDY', 'Deployed']

organizations.each {|name| Organization.find_or_create_by_name(name) }
employments.each {|name| Employment.find_or_create_by_name(name) }
statuses.each {|name| Status.find_or_create_by_name(name) }

usaf_ranks = [
  {:name => 'Airman Basic', :abbr => 'AB', :grade => 'E-1', :value => 1},
  {:name => 'Airman', :abbr => 'Amn', :grade => 'E-2', :value => 2},
  {:name => 'Airman 1st Class', :abbr => 'A1C', :grade => 'E-3', :value => 3},
  {:name => 'Senior Airman', :abbr => 'SrA', :grade => 'E-4', :value => 4}
]

usa_ranks = [{:name => 'Private', :abbr => 'Pvt', :grade => 'E-1', :value => 1}]
usn_ranks = [{:name => 'TodoNavy', :abbr => 'Todo', :grade => 'E-1', :value => 1}]
usmc_ranks = [{:name => 'TodoMarines', :abbr => 'Todo', :grade => 'E-1', :value => 1}]

service_branches = [
  {:name => 'Air Force', :abbr => 'USAF', :ranks_attributes => usaf_ranks},
  {:name => 'Army', :abbr => 'USA', :ranks_attributes => usa_ranks},
  {:name => 'Navy', :abbr => 'USN', :ranks_attributes => usn_ranks},
  {:name => 'Marine Corp', :abbr => 'USMC', :ranks_attributes => usmc_ranks}
]

ServiceBranch.delete_all
Rank.delete_all
ServiceBranch.create(service_branches)
